package main

import (
	_ "helloCms/routers"
	"github.com/astaxie/beego"
	_"helloCms/models"
	"helloCms/models"
)

func CheckId(userExitRoleList []models.Roleinfo,roleId int)(b bool)  {
	b=false
	for  _,v:=range userExitRoleList {
		if v.Id==roleId {
			b=true
			break
		}
	}
	return
}

func CheckRoleAction(roleExitActionList []*models.Actioninfo,actionId int)(b bool)  {
	b=false
	for _,v:=range roleExitActionList{
		if v.Id==actionId{
			b=true
			break
		}
	}
	return
}

func CheckUserAction(userExtActions []models.Useraction,actionId int)(b bool)  {
	b=false
	for _,v:=range userExtActions{
		if v.Actions.Id==actionId{
			b=true
			break
		}
	}
	return
}

func CheckUserActionIsPass(userExtActions []models.Useraction,actionId int)(b bool)  {
	b= false
	for _,v:=range userExtActions{
		if v.Actions.Id==actionId && v.IsPass==1{
			b=true
			break
		}
	}
	return
}


func main() {
	beego.BConfig.WebConfig.Session.SessionOn = true//启用SESSION

	beego.AddFuncMap("checkId",CheckId)
	beego.AddFuncMap("checkRoleAction",CheckRoleAction)
	beego.AddFuncMap("checkUserAction",CheckUserAction)
	beego.AddFuncMap("checkUserActionIsPass",CheckUserActionIsPass)
	beego.Run()
}

